#pragma once
#include "BaseDomain.hpp"

using std::string;
using std::map;
class Input : public BaseDomain
{
public:
    Input(AsyncDriver* mdriver) : BaseDomain(mdriver) {
        this->driver = mdriver;
    }

    void insertText(string txt) {
        map<string, std::variant<int, string, bool, float, nlohmann::json>> params;
        params["text"] = txt;
        this->sendCommandNoWait("Input.insertText", params);
    }

    /// <summary>
    /// Dispatches a key event to the page.
    /// </summary>
    /// <param name="type">,Allowed Values: keyDown, keyUp, rawKeyDown, char</param>
    /// <param name="text">,Text as generated by processing a virtual key code with a keyboard layout. Not needed for for keyUp and rawKeyDown events (default: "")</param>
    /// <param name="key">,Unique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr') (default: "").</param>
    /// <param name="isKeypad">,Whether the event was generated from the keypad (default: false).</param>
    void dispatchKeyEvent(string type, string text, string key, bool isKeypad) {
        map<string, std::variant<int, string, bool, float, nlohmann::json>> params;
        params["type"] = type;
        params["text"] = text;
        params["key"] = key;
        params["isKeypad"] = isKeypad;
        this->sendCommandNoWait("Input.dispatchKeyEvent", params);
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="type">,Allowed Values: mousePressed, mouseReleased, mouseMoved, mouseWheel</param>
    /// <param name="x">,X coordinate of the event relative to the main frame's viewport in CSS pixels.</param>
    /// <param name="y">,Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.</param>
    /// <param name="modifiers">,Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).</param>
    /// <param name="button">Allowed Values: none, left, middle, right, back, forward</param>
    /// <param name="clickCount">Number of times the mouse button was clicked (default: 0).</param>
    void dispatchMouseEvent(string type, int x, int y, int modifiers, string button, int clickCount) {
        map<string, std::variant<int, string, bool, float, nlohmann::json>> params;
        params["type"] = type;
        params["x"] = x;
        params["y"] = y;
        params["modifiers"] = modifiers;
        params["button"] = button;
        params["clickCount"] = clickCount;
        this->sendCommandNoWait("Input.dispatchMouseEvent", params);
    }
};

